package be.kuleuven.cs.mop.domain.model.impl;


import static org.junit.Assert.*;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

import org.junit.*;

import be.kuleuven.cs.mop.TestEnvironment;
import be.kuleuven.cs.mop.domain.exceptions.TaskManagerException;



public class FocusWorkAlgorithmDeadlineTest {
	
	private static TestEnvironment ENV;
	
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {}

	@Before
	public void setUp() throws Exception {
		ENV = TestEnvironment.newInstance();
	}
	
	@After
	public void tearDown() throws Exception {}
	
	
	
	@Test(expected=NullPointerException.class)
	public void testConstructorInvalidNull() {
		new FocusWorkAlgorithmDeadline(null, 0);
	}
	
	@Test(expected=IllegalArgumentException.class)
	public void testConstructorInvalidParam() {
		System.out.println("test:  " + ENV);
		new FocusWorkAlgorithmDeadline(ENV.user1, -1);
	}
	
	@Test
	public void testConstructorValid() {
		new FocusWorkAlgorithmDeadline(ENV.user1, 10);
	}
	
	@Test
	public void testExecuteEmptyCase() {
		final List<TaskImpl> focus =
			new FocusWorkAlgorithmDeadline(ENV.user1, 10).execute();
		assertNotNull(focus);
		assertTrue(focus.isEmpty());
	}
	
	@Test
	public void testExecuteEmptyCase2() {
		try{
			ENV.user1.createTask(
					new Schedule(ENV.datum1, ENV.datum2, ENV.duration-30),
					new HashSet<TaskImpl>(),
					new HashMap<String, Field>(), ENV.testTaskType);
			ENV.user1.createTask(
								new Schedule(ENV.datum3, ENV.datum2, (ENV.duration)),
								new HashSet<TaskImpl>(),
								new HashMap<String, Field>(),
								ENV.testTaskType);
		}
		catch(TaskManagerException e){
			assertTrue(false);
		}
			
				
		final List<TaskImpl> focus =
			new FocusWorkAlgorithmDeadline(ENV.user1, 10).execute();
		assertNotNull(focus);
		assertTrue(focus.isEmpty());
	}

}